home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
oop_tp55.zip
/
LIST2_1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-03-08
|
2KB
|
135 lines
program Listing2_1;
type
SexType = (male, female);
String20 = string[20];
NameRec = record
Last : String20;
Middle : String20;
First : String20;
end;
Person = object
Name : NameRec;
Sex : SexType;
Email : String20;
procedure Init( FName, MName, LName : String20;
Gender : SexType;
E_mail : String20 );
procedure SendMsg( Msg : string );
end;
procedure Person.Init( FName, MName, LName : String20;
Gender : SexType;
E_mail : String20 );
begin
Name.First := FName;
Name.Middle := MName;
Name.Last := LName;
Sex := Gender;
Email := E_mail;
end;
procedure Person.SendMsg( Msg : string );
var
Title : string[3];
begin
if Sex = male then
Title := 'Mr.'
else
Title := 'Ms.';
writeln( 'TO: ', Title, ' ', Name.Last );
writeln( 'ADDRESS: ', Email );
writeln( '-----------------------------------------');
writeln( Msg );
writeln;
end;
var
JohnDoe : Person;
JaneDoe : Person;
NickGogol : Person;
begin
JohnDoe.Init( 'John', 'A.', 'Doe', male, 'EM987' );
JaneDoe.Init( 'Jane', 'A.', 'Doe', female, 'EM789' );
NickGogol.Init( 'Nikolai', 'Vasilievich', 'Gogol',
male, 'DS000' );
JohnDoe.SendMsg( 'Your library books are overdue.' );
NickGogol.SendMsg(
'The books you ordered are at the bookstore.');
JaneDoe.SendMsg(
'The physics midterm has been postponed two weeks.');
end.
{ Listing2-1 }